﻿@{
    ViewBag.Title = "我投资的项目";
    Layout = "~/Views/Shared/_LayoutFore.cshtml";
}

<link href="~/Content/assets/plugins/screen/style.css" rel="stylesheet" />
<div class="RightContrent">
    <div style="margin-left: 50px; margin-right: 50px;">
        <div class="tab-content">
            <div class="line10"></div>
            <div class="line10"></div>
            <div class="tab_title">@ViewBag.Title</div>
            <div class="tab-content">
                <div style="width: 16px; height: 12px; float: left;">
                    <img src="~/Content/Images/leftarraw.png" />
                </div>
            </div>

            <div class="tab-content_border">

                <div class="u-center">
                    <div class="menu-list" align="right">
                        <a href="/Claims/List" class="btn" style="color: white; margin: 0px">去投资</a>
                    </div>
                    <ul class="select">
                        <li class="select-list">
                            <dl id="select1">
                                <dt>筛选日期：</dt>
                                <dd class="select-all selected"><a id="day0" aria-valuetext="">全部</a></dd>
                                <dd><a id="day1" aria-valuetext="3">最近3天</a></dd>
                                <dd><a id="day2" aria-valuetext="30">1个月</a></dd>
                                <dd><a id="day3" aria-valuetext="90">3个月</a></dd>

                            </dl>
                        </li>
                        <li class="select-list">
                            <dl id="select2">
                                <dt>筛选类型：</dt>
                                <dd class="select-all selected"><a id="type0" aria-valuetext="">全部</a></dd>
                                <dd><a id="type1" aria-valuetext="1">待还款</a></dd>
                                <dd><a id="type2" aria-valuetext="2">还款中</a></dd>
                                <dd><a id="type3" aria-valuetext="3">已回款</a></dd>
                            </dl>
                        </li>
                        <li class="select-list">
                            <dl id="select3">
                                <dt>筛选状态：</dt>
                                <dd class="select-all selected"><a id="status0" aria-valuetext="">全部</a></dd>
                                <dd><a id="status1" aria-valuetext="1">投资成功</a></dd>
                                <dd><a id="status2" aria-valuetext="0">投资失败</a></dd>
                                <dd><a id="status3" aria-valuetext="2">流标已退款</a></dd>
                            </dl>
                        </li>
                        <li class="select-result">
                            <dl>
                                <dt>已选条件：</dt>
                                <dd class="select-no">暂时没有选择过滤条件</dd>
                            </dl>
                        </li>
                    </ul>

                    <div id="gridlist">
                    </div>
                </div>

            </div>
            <div class="line10"></div>

        </div>
    </div>

    <form id="conform" method="post">
        <input id="day" type="hidden" name="day" />
        <input id="type" type="hidden" name="type" />
        <input id="status" type="hidden" name="status" />
    </form>

    @* <script src="~/Content/assets/plugins/screen/jquery-1.7.2.min.js"></script>*@
    <script src="~/Content/assets/plugins/screen/script.js"></script>

    <script type="text/javascript">
        ;
        (function (window, undefined, $) {
            $(document).ready(function () {
                var gridopt = {
                    url: options.listUrl,
                    colModel: [
                        { display: '编号', name: 'ID', width: "10%", sortable: true, hide: true, align: 'left', iskey: true },
                        { display: '项目详情', name: 'ProjectName', width: "40%", sortable: true, align: 'left', process: detail },
                        { display: '投资金额', name: 'Amounts', width: "10%", sortable: true, align: 'left' },
                        { display: '投资时间', name: 'InvestTime', width: "20%", sortable: true, align: 'left' },
                        {
                            display: '投标状态', name: 'Status', width: "10%", sortable: true, align: 'left', process: function (value) {
                                if (value == 0) {
                                    return "<span style='color:red'>投资失败</span>";
                                } else if (value == 1) {
                                    return "<span style='color:green'>投资成功</span>";
                                } else {
                                    return "<span>流标已退款</span>";
                                }
                            }
                        },
                        {
                            display: '操作', name: 'ID', width: "15%", sortable: true, align: 'center', process: function (value, cell) {
                                if (cell[4] == 1) {
                                    if (cell[12] != "") {
                                        return "<a title='查看' href='javascript:;' class='btn'  onclick=\"util.Select('" + cell[11] + "')\"></i>查看</a>";
                                    } else {
                                        return "<span>满标后可查看收益</span>";
                                    }
                                } else if (cell[4] == 0) {
                                    return "<a title='删除' href='javascript:;' style='text-decoration:underline;' onclick=\"util.Delete('" + cell[11] + "')\"></i>删除</a>";
                                } else {
                                    return "<a title='删除' href='javascript:;' style='text-decoration:underline;' onclick=\"util.Delete('" + cell[11] + "')\"></i>删除</a>";
                                }

                            }
                        },
                        { display: '年化收益率', name: 'AnnualisedRates', width: "20%", sortable: true, hide: true, align: 'left' },
                        { display: '额外收益率', name: 'AddAnnualisedRates', width: "20%", sortable: true, hide: true, align: 'left' },
                        { display: '发布时间', name: 'CreateTime', width: "20%", sortable: true, hide: true, align: 'left' },
                        { display: '项目期限', name: 'ProjectDuration', width: "20%", sortable: true, hide: true, align: 'left' },
                        { display: '月/天', name: 'DurationMonthOrDay', width: "20%", sortable: true, hide: true, align: 'left' },
                        { display: '投标编号', name: 'SubmitBidNo', width: "20%", sortable: true, hide: true, align: 'left' },
                        { display: '返款时间', name: 'LoanTime', width: "20%", sortable: true, hide: true, align: 'left' }
                    ],
                    sortname: "ID",
                    sortorder: "DESC",
                    title: false,
                    rp: 5,
                    usepager: true,
                    showcheckbox: false
                };

                var xjgrid = new xjGrid("gridlist", gridopt);

                $("#day0,#day1,#day2,#day3").click(function () {
                    $("#day").val($(this).attr("aria-valuetext"));
                    $("#conform").submit();
                });
                $("#type0,#type1,#type2,#type3").click(function () {
                    $("#type").val($(this).attr("aria-valuetext"));
                    $("#conform").submit();
                });
                $("#status0,#status1,#status2,#status3").click(function () {
                    $("#status").val($(this).attr("aria-valuetext"));
                    $("#conform").submit();
                });

                $("#conform").submit(function () {
                    xjgrid.Query(this);
                    return false;
                });
                function detail(value, cell) {
                    var ops = [];
                    ops.push("<a href='/Claims/ToInvest/" + cell[0] + "' style='color:#FF6666;font-size:15px;' target='_blank'><b>", value, "</b></a>");
                    ops.push("(发布时间：", cell[8]);
                    ops.push("<br>年化收益率：", cell[6] * 100 + "% + " + cell[7] * 100 + "%");
                    ops.push("<br>项目期限：", cell[9], cell[10] == 1 ? "个月" : "天");
                    return ops.join("");
                }
                util.Select = function (id) {
                    $.dialog({
                        lock: true,
                        fixed: true,
                        background: '#000', /* 背景色 */
                        opacity: 0.5,       /* 透明度 */
                        width: 960,
                        height: 600,
                        content: "url:/Claims/InvestmentInfo?submitBidNo=" + id,
                        title: '投资详情'
                    });
                };
                util.Delete = function (id) {
                    $.dialog.confirm("确定删除该投资记录？", function () {
                        $.post("/Claims/DeleteMyInvest", { id: id }, function (data) {
                            if (data.Status > 0) {
                                $.dialog.tips(data.Message, 1, "success.gif", function () {
                                    location.href = data.Data;
                                });
                            } else {
                                $.dialog.tips(data.Message, 3, "error.gif");
                            }
                        });
                    })
                }
            });
        })(window, undefined, jQuery);
        var util = {};
        var options = [];
        options = {
            listUrl: '@Url.Action("GetProjectOfMine")'
        };
    </script>
</div>
